<?php
class CreateParameters extends CakeMigration {

/**
 * Migration description
 *
 * @var string
 * @access public
 */
	public $description = '';

/**
 * Actions to be performed
 *
 * @var array $migration
 * @access public
 */
	public $migration = array(
		'up' => array(
			'create_table' => array(
					'parameters' => array(
						'id' => array('type' => 'integer', 'null' => false, 'key'	=> 'primary'),
						'value' => array('type' => 'string', 'null' => false),
						'description' => array('type' => 'string', 'null' => false),
						'type' => array('type' => 'integer', 'null' => false, 'default' => 0),
						'code' => array('type' => 'string'),
						'object' => array('type' => 'string', 'null' => false),
						'indexes' => array(
						      'PRIMARY' => array(
						          'column' => 'id',
						          'unique' => 1)
						  )
					)
			)
		),
		'down' => array(
			'drop_table' => array('parameters')
		),
	);

/**
 * Before migration callback
 *
 * @param string $direction, up or down direction of migration process
 * @return boolean Should process continue
 * @access public
 */
	public function before($direction) {
		return true;
	}

/**
 * After migration callback
 *
 * @param string $direction, up or down direction of migration process
 * @return boolean Should process continue
 * @access public
 */
	public function after($direction) {
		$Parameter = ClassRegistry::init('Parameter');
    if ($direction == 'up') { //add 2 records to statues table
				//for users 
        $data[0]['value'] = '1';
				$data[0]['description'] = 'Active';
				$data[0]['type'] = 0;
				$data[0]['object'] = 'User';

        $data[1]['value'] = '2';
				$data[1]['description'] = 'Active';
				$data[1]['type'] = 0;
				$data[1]['object'] = 'User';

				//for Properties
        $data[2]['value'] = 'required';
				$data[2]['description'] = 'Required';
				$data[2]['type'] = 0;
				$data[2]['object'] = 'Property';

        $data[3]['value'] = 'email';
				$data[3]['description'] = 'Email';
				$data[3]['type'] = 0;
				$data[3]['object'] = 'Property';

        $data[4]['value'] = 'digits';
				$data[4]['description'] = 'Digits';
				$data[4]['type'] = 0;
				$data[4]['object'] = 'Property';

        $data[5]['value'] = 'datepicker';
				$data[5]['description'] = 'Date Picker';
				$data[5]['type'] = 0;
				$data[5]['object'] = 'Property';

				//for Image Variant
        $data[6]['value'] = '100x';
				$data[6]['description'] = 'Small thumb';
				$data[6]['type'] = 1;
				$data[6]['object'] = 'Variant';
				$data[6]['code'] = 'small';

        $data[7]['value'] = '200x250';
				$data[7]['description'] = 'Medium thumb';
				$data[7]['type'] = 1;
				$data[7]['object'] = 'Variant';
				$data[7]['code'] = 'medium';

        $data[8]['value'] = '300x';
				$data[8]['description'] = 'Big thumb';
				$data[8]['type'] = 1;
				$data[8]['object'] = 'Variant';
				$data[8]['code'] = 'big';

        $data[9]['value'] = '1200x';
				$data[9]['description'] = 'Zoom thumb';
				$data[9]['type'] = 1;
				$data[9]['object'] = 'Variant';
				$data[9]['code'] = 'zoom';

				//product status
        $data[10]['value'] = '1';
				$data[10]['description'] = 'Active';
				$data[10]['type'] = 0;
				$data[10]['object'] = 'Product';

        $data[11]['value'] = '2';
				$data[11]['description'] = 'Deactive';
				$data[11]['type'] = 0;
				$data[11]['object'] = 'Product';

				//Post Image
				$data[12]['value'] = '50x';
				$data[12]['description'] = 'Small thumb';
				$data[12]['type'] = 1;
				$data[12]['object'] = 'Post';
				$data[12]['code'] = 'small';

        $data[13]['value'] = '120x90';
				$data[13]['description'] = 'Medium thumb';
				$data[13]['type'] = 1;
				$data[13]['object'] = 'Post';
				$data[13]['code'] = 'medium';

        $data[14]['value'] = '270x180';
				$data[14]['description'] = 'Big thumb';
				$data[14]['type'] = 1;
				$data[14]['object'] = 'Post';
				$data[14]['code'] = 'big';

				//Category type
				$data[15]['value'] = '1';
				$data[15]['description'] = 'Home Page';
				$data[15]['type'] = 0;
				$data[15]['object'] = 'Category';

        $data[16]['value'] = '2';
				$data[16]['description'] = 'Contact Page';
				$data[16]['type'] = 0;
				$data[16]['object'] = 'Category';

        $data[17]['value'] = '3';
				$data[17]['description'] = 'About Us';
				$data[17]['type'] = 0;
				$data[17]['object'] = 'Category';

        $data[18]['value'] = '4';
				$data[18]['description'] = 'Products List';
				$data[18]['type'] = 0;
				$data[18]['object'] = 'Category';

        $data[19]['value'] = '5';
				$data[19]['description'] = 'Posts List';
				$data[19]['type'] = 0;
				$data[19]['object'] = 'Category';

        $data[20]['value'] = '6';
				$data[20]['description'] = 'Information';
				$data[20]['type'] = 0;
				$data[20]['object'] = 'Category';

				//Category status
        $data[21]['value'] = '1';
				$data[21]['description'] = 'Enable';
				$data[21]['type'] = 1;
				$data[21]['object'] = 'Category';

        $data[22]['value'] = '2';
				$data[22]['description'] = 'Disable';
				$data[22]['type'] = 1;
				$data[22]['object'] = 'Category';

        $Parameter->create();
        if ($Parameter->saveAll($data)){
            echo "Parameters table has been initialized";
        }
    } else if ($direction == 'down') {
        //do more work here
    }
		return true;
	}
}
